<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" session="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fun"%>         
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <title>设置平台交易密码</title>

    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <!-- jqgrid-->
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/custom.ui.jqgrid.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/layer/skin/layer.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/jqGrid/css/style.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/css/select2.min.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/jquery.form.js"></script>
    <script src="${pageContext.request.contextPath}/static/js/common.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/i18n/grid.locale-cn.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/jqGrid/js/minified/jquery.jqGrid.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/js/global.js"></script>
	<script src="${pageContext.request.contextPath}/static/plugins/select2-4.0.0/dist/js/select2.min.js"></script>
	<script type="text/javascript"
            src="${pageContext.request.contextPath}/static/plugins/My97DatePicker/WdatePicker.js"></script>

    <style type="text/css">
       .wrapper{
       		padding:20px;
			*+margin-left:270px;
       }    
       .lt{
       	float:left;
       }
       .rt{
       	float:right;
       }
       .panel{
       		padding:20px;
       }
       .clearfix{
       		overflow:hidden;
       }
      .left_box{
			width:100%;
		}
      .txt{
		color:#666;
		font-size:14px;
		width:200px;
		height:34px;
		line-height:34px;
		text-align:right;
		padding-right:20px;
	}
	 input{
	   display:inline-block;
	   height:30px;
	   *+line-height:30px;
	   width:400px;
	   *+width:388px;
	   *+outline:none;
	   *+border:none;
	   border:none;
	   padding:0 20px 0 10px;
	   text-align:left;
	   outline:none;

	}
	.titles{
		font-size:20px;
		*+font-size:18px;
		color:#333;
		overflow:hidden;
		width:100%;
		padding:5px 20px;
		background:#f8f8f8;
	}
	.titles .span1{
		float: left;
	}
	.titles .span2{
		float:right;
	}
	.wraper .btn-info{
		background:#228ded;
		border-color:#228ded;
		width:155px;
		height:36px;
		font-size:20px !important;
		line-height:18px;
		*+line-height:15px;
		outline:none;
	}
	.box{
		margin:10px 0;
		
	}
	input[type="button"]{
		background:#fff;
	}
	.box label{
	   border:1px solid #ccc;
	   border-radius:2px;
	   padding:0px;
       line-height: 28px;
       width:422px;
	}
	.pic_box{
		width:398px;
		height:304px;
	}
    </style>
</head>
<body >
<jsp:include page="../../top.jsp"></jsp:include>
<div class="right">
<div class="wrapper">
	<c:if test="${state == '1'}">
	     <div class="panel panel-default clearfix" style="height:500px;box-size:border-box;padding-right:0px;">
	          <div class="left_box lt">
	          <div style="padding:20px 0 30px 20px;;font-size:16px;color:#000;">您正在为账户<span style="color:red;">${amountName }</span>设置平台交易密码</div>
	          	<form action="" id="form">
				 	<div class="clearfix box">
				 		<div class="lt txt">请输入账户手机号码：</div><label><input type="text" id='tel' name="tel" class="lt"  placeholder="请输入十一位手机号码"/></label>
				 	</div>
				 	<div class="clearfix box">
				 		<div class="lt txt">短信验证码：</div><label style="position:relative;"><input type="text" class="lt" id="y_box" name="code" placeholder="输入短信验证码" />
				 		<input type="button" id="yzm" value="获取验证码" onclick="getCode(this)" style="width:90px;color:#2683dd !important;position:absolute;top:0px;*+top:1px;right:5px;"/></label>
				 	</div>
				 	<div class="clearfix box">
				 		<div class="lt txt">请输入新密码：</div><label><input type="password" class="lt" placeholder="请输入六位数密码" id="payPassword" name="payPassword"/></label>
				 	</div>
				 	<div class="clearfix box">
				 		<div class="lt txt">请再输入新密码：</div><label><input type="password" class="lt"  placeholder="请输入六位数密码" id="payPasswordRepeat"/></label>
				 	</div>
				 	<input type="button" class="btn btn-info" value="保存" style="margin-left:200px;margin-top:20px; width:110px;background:#2e8ded !important;border-color:#2e8ded !important;" onclick="save()"/>
		 		</form>
	          </div>    
	     </div>
     </c:if>
     
     <c:if test="${state == '2'}">
     	<div class="panel panel-default clearfix" style="height:500px;box-size:bordeer-box;padding-right:100px;">
	          <div class="left_box lt">
	          <div style="padding:40px 0 10px 40px;font-size:16px;color:#333;font-weight:600;font-family:微软雅黑 !important;">您已为账户<span style="color:red;">${amountName }</span>设置了平台交易密码，如若修改请点击下方修改按钮</div>
	          	<form action="">
				 	<input type="button" class="btn btn-info" value="修改" style="margin-left:44px;margin-top:13px;line-height:16px;
    font-size: 16px !important; width:110px;background:#2e8ded !important;border-color:#2e8ded !important;" onclick="update()"/>
				 	
				 	<!-- <input type="button" class="btn btn-info" value="支付" style="margin-left:100px;margin-top:20px;line-height: 18px; width:110px;background:#2e8ded !important;border-color:#2e8ded !important;" onclick="testPayOrder()"/> -->
		 		</form>
	          </div>    
	     </div>
     </c:if>
 </div>
 </div>
 <script type="text/javascript">
 function getCode(thisbtn){
	 var tel = $("#tel").val();
	 if(!(/^1[34578]\d{9}$/.test(tel))){ 
		 layer.msg("请输入正确的手机号");
	 }else{
		 $.ajax({
		        type: "POST",
		        async: false,
		        url: '/admin/userWallet_sendSms4PayPassword.action',
		        data: "tel=" + tel,
		        success: function (data) {
		            data = eval("(" + data + ")");
		            if(data.code=='1'){
		            	layer.msg('发送成功');
		            	var nums=60,tim="";
		        		var btn=thisbtn;
		        		btn.disabled=true;
		        		btn.value=nums+"秒后重试";
		        		var y_box=document.getElementById("y_box");
		        		y_box.removeAttribute("disabled");
		        		y_box.focus();
		        		tim=setInterval(del, 1000);
		        		function del(){
		        			nums--;
		        			if(nums>0){
		        				
		        				btn.value=nums+"秒后重试";
		        			}else{
		        				clearInterval(tim);
		        				btn.disabled=false;
		        				btn.value="获取验证码";
		        				nums=10;
		        			}
		        		}
		            	
		            }else{
		            	layer.alert(data.msg);	
		            }
		        }
		    });
	 }
}
 
 function save(){
	 var tel = $("#tel").val();
	 if(!(/^1[34578]\d{9}$/.test(tel))){ 
		 layer.msg("请输入正确的手机号");
		 return;
	 }
	 var code = $("#y_box").val();
	 if(code==""){
		 layer.msg("请输入验证码");
		 return;
	 }
	 var code = $("#y_box").val();
	 if(code==""){
		 layer.msg("请输入验证码");
		 return;
	 }
	 var payPassword = $("#payPassword").val();
	 if(payPassword==""){
		 layer.msg("请输入支付密码");
		 return;
	 }
	 var payPasswordRepeat = $("#payPasswordRepeat").val();
	 if(payPasswordRepeat!=payPassword){
		 layer.msg("支付密码不一致");
		 return;
	 }
	 
	 $.ajax({
	        type: "POST",
	        async: false,
	        url: '/admin/userWallet_updatePayPassword.action',
	        data: $("#form").serialize(),
	        success: function (data) {
	            data = eval("(" + data + ")");
	            if(data.code=='1'){
	            	window.location.reload();
	            }else{
	            	layer.alert(data.msg);	
	            }
	        }
	    });
 }
 
 function update(){
		layer.open({
            type: 2,
            title: ['修改平台交易密码', 'font-weight:bold'],
            //title:false,
            shadeClose: true, //点击遮罩关闭层
            area: ['800px', '360px'],
            scrollbar: false,
            content: '${pageContext.request.contextPath}/admin/userWallet_updatePayPasswordView.action'
          
        });
	 
 }
 
 function testPayOrder(){	
	var index=layer.open({
         type: 2,
		 closeBtn: 0,//不显示关闭按钮
         //title: ['支付', 'font-weight:bold'],
         title:false,
         shadeClose: true, //点击遮罩关闭层
         area: ['560px','50%'],
         scrollbar: false,
         content: '${pageContext.request.contextPath}/admin/userWallet_payOrderView.action?orderId=1'
		 
     });
 }	
 </script>
</body>
</html>
